package com.renwenhao.dao;

import com.renwenhao.enyity.User;
import com.renwenhao.util.DruidUtil;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

public class LoginDao {

    public User getUser(User u){
        JdbcTemplate jdbcTemplate = new JdbcTemplate(DruidUtil.getDataSource());
        try {
            User user = jdbcTemplate.queryForObject("select * from user where username = ? && password = ?", new BeanPropertyRowMapper<User>(User.class), u.getUsername(), u.getPassword());
            return user;
        } catch (Exception e){
            return null;
        }
        
    }

}
